home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / HLPublish.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  5KB  |  165 lines

  1. /*
  2.  * HLPublish.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: April 18, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.02
  9.  */
  10. call pragma('stack',20000);
  11.  
  12. /*
  13.  * open rexxsupport.library -- needed for some functions
  14.  */
  15. if ~show('L',"rexxsupport.library") then do
  16.   if addlib('rexxsupport.library',0,-30,0) then do
  17.       /* everything's ok */
  18.     end;
  19.   else do
  20.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  21.     say 'Cannot operate HLPublish.rexx without this library - sorry!';
  22.     exit 10;
  23.     end;
  24.   end;
  25.  
  26. /*
  27.  * This will automatically direct the script to the proper
  28.  * software, if it is running.
  29.  */
  30. prtnme = 'IP_Port'; /* assume Image Professional */
  31. if show('P','IP_Port') = 0 then do
  32.   if show('P','IM_Port') = 0 then do
  33.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  34.     say "This script requires IP, IM or IM F/c to run!";
  35.     exit(20);
  36.     end;
  37.   else do
  38.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  39.     end;                 /* We make em, user's break em.          */
  40.   end;
  41.  
  42.   /*
  43.    * This code attempts to read a file called "picmdpath" from REXX:
  44.    * If it can't find it, the script will assume that the commands
  45.    * associated with this PI Module are in "c:". If the file exists,
  46.    * the script will look in the path that is specified in the file.
  47.    * If you create this file, you MUST put a complete, correct path
  48.    * in it; if the commands are in a sub-directory, you have to put
  49.    * the trailing slash on the path (like, device:dir/).
  50.    * 
  51.    */
  52.   cmdpath = 'c:';
  53.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  54.     do
  55.       cmdpath = readln(fhandle);
  56.       call close(fhandle);  /* close the file    */
  57.     end
  58.  
  59. options;
  60. address;
  61.  
  62.   address(prtnme);
  63.   options results;
  64.   'current';
  65.   bufdata = result; /* get name of buffer, if there is one */
  66.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  67.   if bname ~= '<none>' then do
  68.     bufname = bname;
  69.     end;
  70.  
  71.   address(prtnme);
  72.  
  73. 'tofront';
  74.  
  75. options results;
  76. 'gadgets "Publish","as RGB","Publish","as CMYK","Publish","as GREY","Publish","as B&W"';
  77. ptype = result-1;
  78. options;
  79. if ptype < 0 then do
  80.   address;
  81.   exit 0;
  82.   end
  83.  
  84.   if ptype < 3 then do
  85.     options results;
  86.     'askprop '||'"Number of bitplanes per color channel?" 8 1 8'
  87.     planes = result;
  88.     options;
  89.   end
  90.  
  91.   if ptype = 3 then do
  92.     options results;
  93.     'askprop '||'"Luma threshold for black level?" 50 1 100'
  94.     planes = result;
  95.     options;
  96.   end
  97.  
  98.   options results;
  99.   'jackin';
  100.   jackadr = result;
  101.   options;
  102.  
  103.   'wbtofront';
  104.   'lockimage '||bnum;
  105.   address command cmdpath||'HLPublish '||jackadr||' '||ptype||' '||planes;
  106.   'unlockimage '||bnum;
  107.  
  108.   address(prtnme);
  109.   'imtofront';
  110.   address;
  111.  
  112.   exit 0;
  113.  
  114. /*
  115.  * gimmepath
  116.  *
  117.  * This takes the provided argument and sucks the path out of it, then
  118.  * returns that path to the caller, sans file name.
  119.  */
  120. gimmepath:
  121.   arg fullnamegx;
  122.     tempgx = reverse(fullnamegx);
  123.     lengx = length(fullnamegx);   /* get length of string */
  124.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  125.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  126.     seploc = 0; /* assumes current dir, no path supplied */
  127.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  128.       seploc = (lengx - slashdex)+1;
  129.       end;
  130.     else do
  131.       if colondex ~= 0 then do /* we assume we are on a device */
  132.         seploc = (lengx - colondex)+1;
  133.         end;
  134.       end;
  135.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  136.   gxpath = left(fullnamegx,seploc);
  137.   return(gxpath);
  138.  
  139. /*
  140.  * Since this script can't be expected to know where the CD of the user
  141.  * is when this cmd is invoked, we have to check the path the user
  142.  * provides - if it's not specified right from a root, then we have
  143.  * to make it a complete specification from the root.
  144.  */
  145. expandfilename:
  146.   parse arg jfile;
  147.   if index(jfile,':') = 0 then do
  148.     curdir = pragma(D);
  149.     if right(curdir,1) ~= ':' then do
  150.       if right(curdir,1) ~= '/' then do
  151.         if curdir ~= '' then do
  152.           curdir = curdir || '/';
  153.           end;
  154.         end;
  155.       end;
  156.     jfile = curdir||jfile;
  157.     end;
  158.   return(jfile);
  159.  
  160. rvalue:
  161.   wordnum = c2d(readch(fhandle,1)) * 256;
  162.   wordnum = wordnum + c2d(readch(fhandle,1));
  163.   return wordnum;
  164.  
  165.